﻿<?php
/**  
* SuppliesView.php
* 
*/

require_once(CLASS_PATH."/__autoload.php");

class SuppliesView extends MakerPool
{
   protected function getResult($result)
   {
	  $arr = $arrStr = $arrMaker = array();	   
	  $flagMaker = $flagType = $data = $maker = $arrBlock = $linkSerial = null;     
	  $i = 0;
	  
      while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
	  {
		$maker = $row['sMaker']; 
		$makerStr = explode('(', $maker);	
			
		$makerStr = explode(' ', $makerStr[0]);	
		$makerStr = $makerStr[0];		
		$type  = $row['sType'];
		
		$encode_Maker  = urlencode($maker);
		$rst 	= $this->sameCompany($maker) ;
		
		
		if(empty($rst))
		{
			$arr[] 	   = (sizeof($arr)) ? "</dl>" : null ;	
			$arr[]     = "<dl><dt><h2 id='s{$i}'><a href='goto?goMaker=$encode_Maker' title='$maker 홈피로 이동' >{$maker}</a></h2></dt>";
			$arrMaker[]= "<a href='#s{$i}' >{$makerStr}</a>";		   
			
			$i++;
		}
		 
		 $arr[] 	= "<dd>" ;
		 $arr[] 	= $this->sameType($type) ;
		 
		 $sName 	= urlencode($row['sName']);
		 $color 	= trim($row['sColor']);
		 $comment 	= trim($row['sComment']);		
		 $unit 		= trim($row['sUnit']);
	     $quantity 	= trim($row['sQuantity']);
	//=================
	     $eco 		= trim($row['eco']);	
	//================	 		 
		 $arrStr 	= $this->cleanKeyword($this->load_args, ' ');
		 $length 	= count($arrStr);

		 while($length--)
		 {	
			$row['sName'] = $this->addMark($arrStr[$length], $row['sName']);
		 }
		 
		 $encoded_linkSerial= (isset($row['spSerial'])) ? urlencode($row['spSerial']) : null;
		 $linkSerial 		= (!!$encoded_linkSerial) ? "|{$encoded_linkSerial}" : null;
		 $isShort			= ($row['short'] == 'TRUE') ? "class='t' title='정품 생산이 단종된 제품'" : null;
		 $arr[] = "<span data-width=300 ><a href='/2013p79/common/class/search/supprt.php?sSerial={$row['sSerial']}{$linkSerial}&sName=$sName' data-serial='{$row['sSerial']}' $isShort  class='box menu-2' contextmenu='html5polyfill'  > {$row['sName']} </a></span>";
		 $arr[] = (!empty($color)) ? "<span data-width=100 >$color</span>" : "<span data-width=100 > </span>";		 
		 $arr[] = (!empty($unit)) ? "<span data-width=60 >$unit</span>" : "<span data-width=60 > </span>";
		 $arr[] = (!empty($quantity)) ? "<span >$quantity</span>" : "<span > </span>";

		 $arr[] = (!empty($comment)) ? "<br /><span class='sType'></span> <span class='leftpadding20' data-width=630 > &bull;&hellip; {$comment} </span> " : null;
		 $arr[] = '</dd>';  
	  }   // END OF while
	  
	  $this->set_numShowMaker(5);   // #makerpool maker 갯수 지정
	  $arrMaker = $this->arrangeMaker($arrMaker);
	  
	  $arr 		= '<section id="searchResult">'.implode('', $arr)."</dl></section>".$this->get_goTopButton();
	  $data 	= $arrMaker."<div id='showChoice' ></div>".$arr;
	  header("Content-type:text/html; charset=utf-8");    // html형식으로 데이터를 전송하는 경우 적용  
	//   header("Content-type:application/text; charset=utf-8");    // text형식으로 데이터를 전송하는 경우 적용 
	  return  $data; 
	}    
  
}
?>

